const path = require('path')
//import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginImport from 'vite-plugin-babel-import';

// 转发接口
const proxyIp = 'http://192.168.1.105:4000';

module.exports = {
    base: '/vue3',//设置基本路径
    assetsDir: 'static',
    alias: {
        '/@/': path.resolve(__dirname, './src')
    },
    plugins: [
        vue(),
        vitePluginImport([
            {
                libraryName: 'element-plus',
                libraryDirectory: 'es',
                style(name) {
                return `element-plus/lib/theme-chalk/${name}.css`;
            },
            }
        ])
    ],
    proxy: {// 配置多个代理(配置一个 proxy: 'http://localhost:4000' )
        '/api': {
            target: proxyIp,
            ws: true,
            changeOrigin: true,
            pathRewrite: {
                '^/api': '/mock'
            }
        },
        '/foo': {
            target: proxyIp
        }
    }
}